<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page import="com.infodms.dms.common.Constant"%>
<%@ page import="java.util.*"%>
<%@taglib uri="/jstl/cout" prefix="c" %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="${contextPath}/common/jsp_head_new.jsp" />
<title>经销商仓库维护</title>
</head>
<script type="text/javascript">
function txtClr(valueId) {
	document.getElementById(valueId).value = '' ;
}
</script>
<% String contextPath = request.getContextPath();  %>
<body onload="setShow('${tmDealerWarehousePO.dealerId}');setShow('${tmDealerWarehousePO.warehouseType}') ;"> 
	<div class="navigation"><img src="<%=contextPath%>/img/nav.gif" />&nbsp;当前位置：  整车销售 &gt; 经销商库存管理 &gt; 仓库修改维护</div>
	<form id="fm" name="fm" method="post">
		<input type="hidden" id="warehouseId" name="warehouseId" value="${tmDealerWarehousePO.warehouseId}" />
		<table class="table_query" border="0">
			<tr>
				<td width="20%" class="tblopt"><div align="right">仓库名称：</div></td>
				<td width="39%" >
      				<input name="warehouseName"   datatype="0,is_textarea,30"  type="text" id="warehouseName" class="SearchInput" value="${tmDealerWarehousePO.warehouseName}" size="20" />
    			</td>
    			<td width="20%" class="tblopt"><div align="right">仓库类型：</div></td>
				<td width="39%" >
      				<label>
					<script type="text/javascript">
						genSelBoxExp("warehouseType",<%=Constant.DEALER_WAREHOUSE_TYPE%>,"${tmDealerWarehousePO.warehouseType}",false,"short_sel","onchange='setShow(this.value)'","false",'');
					</script>
				</label>
    			</td>
			</tr>
			<tr>
				<td width="20%" class="tblopt"><div align="right">经销商：</div></td>
				<td width="39%" >
      				<select name="dealer" id="dealer__" onchange="changeFleet(this.value)">
      					<c:forEach var="dealerList_D" items="${dealerList }">
      						<c:if test="${tmDealerWarehousePO.dealerId == dealerList_D.DEALER_ID}">
      							<option selected value="${dealerList_D.DEALER_ID }">${dealerList_D.DEALER_NAME }-${dealerList_D.DEALER_CODE }</option>
      						</c:if>
      						<c:if test="${tmDealerWarehousePO.dealerId != dealerList_D.DEALER_ID}">
      							<option value="${dealerList_D.DEALER_ID }">${dealerList_D.DEALER_NAME }-${dealerList_D.DEALER_CODE }</option>
      						</c:if>
      					</c:forEach>
      				</select>
    			</td>
    			<td width="20%" class="tblopt" id="lowDel__"><div align="right">代管经销商：</div></td>
				<td width="39%" >
      			<div id="lowDel__L">
      			<input type="hidden"  name="lowID" id="lowID" size="15" value=""/>
				<input type="text"  name="lowDel" id="lowDel" size="15" value="${dealerPo1.dealerCode}" readonly="readonly" />
				<input name="button2" type="button" class="mini_btn" onclick="showOrgDealer('lowDel', 'lowID', 'false', '', 'true');" value="..." />
				<input type="button" class="normal_btn" onclick="txtClr('lowDel');" value="清 空" id="clrBtn" />
				</div>
    			</td>
			</tr>
			<tr>
				<td width="20%" class="tblopt"><div align="right">是否关闭：</div></td>
				<td width="39%" >
      				<label>
					<script type="text/javascript">
						genSelBoxExp("warehouseStatus",<%=Constant.STATUS%>,"${tmDealerWarehousePO.status}",false,"short_sel",'',"false",'');
					</script>
				</label>
    			</td>
    			<td width="20%" class="tblopt"><div align="right">备注：</div></td>
				<td >
				<textarea id="remark"  name="remark" rows="3" cols="20"  datatype="1,is_textarea,2000">${tmDealerWarehousePO.remark}</textarea>
    			</td>
			</tr>
			<tr>
			<td colspan="4" align="center"><input type="button" class="cssbutton" name="button3" onClick="modMyStore();" value="保存"/>
			<input type="button" class="cssbutton" name="button4" onClick="toBack();" value="返回"/></td>
			</tr>
		</table>
	</form>
	<script>
		function modMyStore(){
			var a=document.getElementById("dealer__").value;
			var b=document.getElementById("lowID").value;
			if(a==b){
						MyAlert("自身不能作为代交经销商！");
				}else{
			var lowDelA = document.getElementById('lowDel').value ;
			var warehouseTypeA = document.getElementById('warehouseType').value ;
			if(warehouseTypeA == <%=Constant.DEALER_WAREHOUSE_TYPE_02 %> && lowDelA == '') {
				MyAlert("请选择代管经销商!") ;
				return false ;
			}
			if(submitForm('fm')){
				fm.action = '<%=contextPath%>/sales/storageManage/MyStore/modMyStore.do';
 				fm.submit();
			}
				}
		}
		function toBack(){
			fm.action = '<%=contextPath%>/sales/storageManage/MyStore/detailMyStore.do';
				fm.submit();
		}

		function changeFleet(value) {
			// alert(value);
			var sLowDelName = "" ;
			var sLowDelId = "" ;
			var i = 0;
			
			<c:forEach var="lowDelList_D" items="${lowDelList }">
				if(${lowDelList_D.PARENT_DEALER_D} == value) {
					sLowDelName =sLowDelName+'${lowDelList_D.DEALER_NAME}' + "," ;
					sLowDelId = sLowDelId + '${lowDelList_D.DEALER_ID}' + "," ;
					i++ ;
				}
			</c:forEach>
				document.fm.lowDel__L.options.length=i;
				for(var j=0; j<i; j++) {
					if (${tmDealerWarehousePO.manageDealerId} == sLowDelId.split(',')[j]) {
						document.fm.lowDel__L.options[j].value=sLowDelId.split(',')[j];
						document.fm.lowDel__L.options[j].text=sLowDelName.split(',')[j];
						document.fm.lowDel__L.options[j].selected = true ;
					}
					else {
						document.fm.lowDel__L.options[j].value=sLowDelId.split(',')[j];
						document.fm.lowDel__L.options[j].text=sLowDelName.split(',')[j];
						}
				}
			}

		function setShow(value) {
			// alert(value) ;
			var iValue = <%=Constant.DEALER_WAREHOUSE_TYPE_01 %>
			if (value == iValue) {
				document.getElementById("lowDel__").style.display = "none";
				document.getElementById("lowDel__L").style.display = "none";
				}
			else {
				document.getElementById("lowDel__").style.display = "inline";
				document.getElementById("lowDel__L").style.display = "inline" ;
				}
		} 
		
	</script>
</body>
</html>
		